package test.project;

import java.io.IOException;

import org.apache.solr.client.solrj.SolrQuery;
import org.apache.solr.client.solrj.SolrServerException;
import org.apache.solr.client.solrj.impl.CloudSolrClient;
import org.apache.solr.client.solrj.response.QueryResponse;

public class App {
	
	public static void query() {
		CloudSolrClient client = new CloudSolrClient("192.168.5.34:2181");
		SolrQuery query = new SolrQuery("*:*");
		try {
			QueryResponse qr = client.query("article", query);
			System.out.println(qr);
		} catch (SolrServerException e) {
			e.printStackTrace();
		} catch (IOException e) {
			e.printStackTrace();
		} finally {
			try {
				client.close();
			} catch (IOException e) {
				e.printStackTrace();
			}
		}
	}
	
	public static void deleteAll() {
		CloudSolrClient client = new CloudSolrClient("192.168.5.34:2181");
		try {
			client.deleteByQuery("article", "*:*");
			client.commit("article");
		} catch (SolrServerException e) {
			e.printStackTrace();
		} catch (IOException e) {
			e.printStackTrace();
		} finally {
			try {
				client.close();
			} catch (IOException e) {
				e.printStackTrace();
			}
		}
	}
	
	public static void main(String[] args) {
		deleteAll();
	}

}
